﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace XBMC.Cache.Manager
{
    public class DBObjectPath
    {
        [DBField("idPath")]
        public int PathID { get; set; }
        [DBField("idFile")]
        public int FileID { get; set; }
        [DBField("strPath")]
        public string SourcePath { get; set; }
        [DBField("strFilename")]
        public string SourceFile { get; set; }

        public string PhysicalFolder
        {
            get
            {
                string path = null;

                try
                {
                    if (SourcePath.Substring(0, 6).ToLower() == "smb://")
                    {
                        path = SourcePath.Substring(4);
                        path = path.Replace("/", Path.DirectorySeparatorChar.ToString());
                    }
                }
                catch { }

                return path;
            }
        }

        public string PhysicalFile
        {
            get
            {
                return Path.Combine(PhysicalFolder, SourceFile);
            }
        }
    }
}
